/*
    SUSAN® - Sole of Unix Save ANything

      Copyright (C) 2011-2016 Skyatlas Co. LTD

   

   
*/

#ifndef BAREOS_DIRD_SCHEDULER_H_
#define BAREOS_DIRD_SCHEDULER_H_

#include "dird/job_trigger.h"

#include <memory>
#include <functional>

class JobControlRecord;

namespace directordaemon {

class JobResource;
class SchedulerTimeAdapter;
class SchedulerPrivate;

class Scheduler {
 public:
  Scheduler() noexcept;
  Scheduler(std::unique_ptr<SchedulerTimeAdapter> time_adapter,
            std::function<void(JobControlRecord*)> ExecuteJob) noexcept;
  ~Scheduler();

  void Run();
  void Terminate();
  void ClearQueue();
  void AddJobWithNoRunResourceToQueue(JobResource* job, JobTrigger job_trigger);
  static Scheduler& GetMainScheduler() noexcept;

 private:
  std::unique_ptr<SchedulerPrivate> impl_;
};

} /* namespace directordaemon */

#endif  // BAREOS_DIRD_SCHEDULER_H_
